<template>
  <a-card :bordered="false">
      <a-comment style="background-color: #80c4ff; border-radius: 6px">
          <template #author><a>管理员</a></template>
          <template #avatar>
            <a-avatar src="https://joeschmoe.io/api/v1/random" alt="Han Solo" />
          </template>
          <template #content>
            <p>1.可用余额：{{Merchantaccount}}</p>
            <p>2.开户银行：{{BankName}}</p>
            <p>3.代征主体：{{MerchantName}}</p>
          </template>
          <template #datetime>
            <a-tooltip :title="1">
            </a-tooltip>
          </template>
        </a-comment>

    <div class="table-page-search-wrapper" style="margin-top:50px">
      <a-form layout="inline">
        <a-row :gutter="10">
          <a-col :md="4" :sm="24">
            <a-form-item label="查询类别">
              <a-select allowClear v-model="queryParam.condition">
                <a-select-option key="BusinessOrderNo">单号</a-select-option>
                <a-select-option key="PayingAccountName">客户名称</a-select-option>
                <a-select-option key="PayingBankName">付款银行名称</a-select-option>
                <a-select-option key="ServiceBank">服务商银行名称</a-select-option>
                <a-select-option key="ServiceAccountNo">银行账号</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="24">
            <a-form-item>
              <a-input v-model="queryParam.keyword" placeholder="关键字" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-button type="primary" @click="() => {this.pagination.current = 1; this.getDataList()}">查询</a-button>
            <a-button style="margin-left: 8px" @click="() => (queryParam = {})">重置</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <a-table
      ref="table"
      :columns="columns"
      :rowKey="row => row.Id"
      :dataSource="data"
      :pagination="pagination"
      :loading="loading"
      @change="handleTableChange"
      :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
      :bordered="false"
      size="middle"
    >
    </a-table>

  </a-card>
</template>

<script>

const columns = [
  { title: '付款方', dataIndex: 'PayingAccountName', width: '20%' },
  { title: '汇款账号', dataIndex: 'PayingAccount', width: '20%' },
  { title: '银行流水', dataIndex: 'RechargeAmount', width: '10%' },
  { title: '入账时间', dataIndex: 'CreatTime', width: '20%' },
  { title: '到账金额', dataIndex: 'AccountAmount', width: '20%' },

  // { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' } }
]

export default {
  mounted() {
    this.getDataList()
  },
  data() {
    return {
      data: [],
      MerchantName:'',
      Merchantaccount:'',
      BankName:'',
      pagination: {
        current: 1,
        pageSize: 5,
        showSizeChanger: true,
        showQuickJumper: true,
        total: 0, // 总数，必须先有
        showTotal: (total, range) => `总数:${total} 当前:${range[0]}-${range[1]}`,
        onShowSizeChange: (current, pageSize) => {
          this.pagination.current = 1;
          this.pagination.pageSize = pageSize;
          this.getDataList(); //显示列表的接口名称
        },
        // 改变每页数量时更新显示
        onChange: (current, size) => {
          this.pagination.current = current;
          this.pagination.pageSize = size;
          this.getDataList();
        },
      },
      filters: {},
      sorter: { field: 'Id', order: 'asc' },
      loading: false,
      columns,
      queryParam: {},
      selectedRowKeys: []
    }
  },
  methods: {
    handleTableChange(pagination, filters, sorter) {
      this.pagination = { ...pagination }
      this.filters = { ...filters }
      this.sorter = { ...sorter }
      this.getDataList()
    },
    getDataList() {
      this.selectedRowKeys = []

      this.loading = true
      this.$http
        .post('/Base_leasesystem_accountrecharge/leasesystem_accountrecharge/GetAccountInfo', {
          PageIndex: this.pagination.current,
          PageRows: this.pagination.pageSize,
          SortField: this.sorter.field || 'Id',
          SortType: this.sorter.order,
          Search: this.queryParam,
          ...this.filters
        })
        .then(resJson => {
          this.loading = false
          this.MerchantName = resJson.Data.MerchantName
          this.BankName = resJson.Data.BankName
          this.Merchantaccount = resJson.Data.Merchantaccount
          this.data = resJson.Data.RechargeList
          const pagination = { ...this.pagination }
          pagination.total = resJson.Data.Total
          this.pagination = pagination
        })
    },
    onSelectChange(selectedRowKeys) {
      this.selectedRowKeys = selectedRowKeys
    },
    hasSelected() {
      return this.selectedRowKeys.length > 0
    },
    
  }
}
</script>

<style>
.ant-table-thead > tr > th
{
  font-weight: 600;
  color: #333333;
}
</style>